const path = require('path')

const resolve = dir => {
  return path.join(__dirname, dir)
}
const CompressionPlugin = require('compression-webpack-plugin');
module.exports = {
  lintOnSave: false,
  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src')) // key,value自行定义，比如.set('@@', resolve('src/components'))
      .set('_c', resolve('src/components'))
  },
  // 这里写你调用接口的基础路径，来解决跨域，如果设置了代理，那你本地开发环境的axios的baseUrl要写为 '' ，即空字符串
  devServer: {
    host: '127.0.0.1',
    port: 9527,
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:8020',
        ws: true,
        pathRewrite: {
          '^/api': '/'//重写
        }
      }
    }
  },
  productionSourceMap: false,
  // 部署优化
  configureWebpack: {
    // GZIP压缩
    plugins: [
      new CompressionPlugin({
        test: /\.js$|\.html$|\.css/, // 匹配文件
        threshold: 10240 // 对超过10k文件压缩
      })
    ]
  }
}
